#include "timer.h"

#include <QDateTime>

void Timer::UpdateRuningTime(time_t max_require_ms)
{
    if (runningMs >= max_require_ms)
        return;
    previousMs = currentMs;
    currentMs = GetTime();
    runningMs += currentMs - previousMs;
}

void Timer::Reset()
{
    start_ms = GetTime();
    currentMs = previousMs = start_ms;
    runningMs = 0;
}

long long Timer::GetTime()
{
    return QDateTime::currentMSecsSinceEpoch();
}
